using System;
using System.Collections.Generic;
using System.Text;
using EnvDTE;
using System.IO;

namespace ACP.Tortuga_Package {
	public class SelectedItemHelper {

		public static SelectedItemCollection GetSelectedItems(_DTE application) {
			SelectedItemCollection selectedItems = new SelectedItemCollection();
			if (application != null) {
				SelectedItems items = application.SelectedItems;
				int length = application.SelectedItems.Count;
				for (int i = 1; i < length + 1; i++) {
					SelectedItem item = application.SelectedItems.Item(i) as SelectedItem;
					if (item!= null)
						selectedItems.Add(item);
				}
			}
			return selectedItems;
		}


		#region Paths
		public static string GetProjectPath(Project proj) {
			return GetParentDirectory(proj.FullName);
		}

		public static string GetSolutionPath(Solution sol) {
			return GetParentDirectory(sol.FileName);
		}

		public static string GetSolutionPath(_DTE application) {
			return GetSolutionPath(application.Solution);
		}

		public static string GetPath(ProjectItem item) {
			return item.get_FileNames(1);
		}

		public static string GetSolutionDirectory(_DTE application) {
			return GetParentDirectory(GetSolutionPath(application));
		}

		public static string GetParentDirectory(string path) {
			return Directory.GetParent(path).FullName;
		}

		#endregion
	}

}
